<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packageName}.${moduleName}.model.dao.${className}Dao">
    <sql id="allColumns">
        <#assign insertField>
        <#list columnList as column>
            <#if column.colTypeName == "DATE">
        DATE_FORMAT(${column.colName},'%Y-%m-%d') ${column.fieldName},
            <#elseif column.colTypeName == "DATETIME">
        DATE_FORMAT(${column.colName},'%Y-%m-%d %H:%i:%s') ${column.fieldName},
            <#else>
        ${column.colName} ${column.fieldName},
            </#if>
        </#list></#assign>
${insertField?substring(0, insertField?last_index_of(","))}
    </sql>

    <select id="get" parameterType="java.lang.String" resultType="${packageName}.${moduleName}.model.po.${className}">
        SELECT <include refid="allColumns"/>
        FROM ${tableName}
        WHERE id = ${"#"}{id}
    </select>

    <select id="findList" parameterType="${packageName}.${moduleName}.model.po.${className}" resultType="${packageName}.${moduleName}.model.po.${className}">
        SELECT <include refid="allColumns"/>
        FROM ${tableName}
    </select>

    <insert id="insert" parameterType="${packageName}.${moduleName}.model.po.${className}">
        INSERT INTO ${tableName}(
       <#assign insertField><#list columnList as column>
        ${column.colName},
        </#list></#assign>
${insertField?substring(0, insertField?last_index_of(","))}
        ) VALUES (
        <#assign insertJavaField><#list columnList as column>
        ${"#"}{${column.fieldName}},
        </#list></#assign>
${insertJavaField?substring(0, insertJavaField?last_index_of(","))}
        )
    </insert>

    <!-- 删除-->
    <update id="delete" parameterType="${packageName}.${moduleName}.model.po.${className}">
        UPDATE ${tableName}
        SET sts = 'N', upd_usr_id=${"#"}{currUsrId}, upd_usr_nam=${"#"}{currUsrNam}, upd_dat=sysdate()
        WHERE id = ${"#"}{id}
    </update>

    <!-- 修改 -->
    <update id="update" parameterType="${packageName}.${moduleName}.model.po.${className}">
    <#assign updateField><#list columnList as column>
        ${column.colName} = ${"#"}{${column.fieldName}},
    </#list> </#assign>

        UPDATE ${tableName}
        SET
    ${updateField?substring(0, updateField?last_index_of(","))}
        WHERE id = ${"#"}{id}
    </update>


</mapper>